
<script type="text/javascript">

function loadURL(url1) {
	$(".ui.dimmer").addClass("active");
	$.ajax({
		url : url1,
		async : true,
		success : function(result) {
			$("#stuhomehs").html(result);
			$(".ui.dimmer").removeClass("active");
		}
	});
	$(".ui.dropdown.item").click(function() {
		$('.ui.dropdown').dropdown();
	});
}
$(document).ready(function() {
	$(".hm_item_home").click(function(e){loadURL("home.php?op=loadtemple&mod=home&node=home&uid=<?php global $uid;echo $uid;?>");});
	$(".hm_item_edit").click(function(e){loadURL("home.php?op=loadtemple&mod=home&node=settings&uid=<?php echo $uid;?>");});
	$(".hm_item_message").click(function(e){loadURL("home.php?op=loadtemple&mod=home&node=message&uid=<?php echo $uid;?>");});
 	$("#hm_item_home").click();
});

function getuid(){
	return $(".ui.main.container").attr("uid");
}
function errorShow(errormess){
	$("#errorcontent").text(errormess);
	$("#errormessage").modal('show');
}

function resultShow(resultmessage){
	$("#resultcontent").text(resultmessage);
	$("#resultmessage").modal('show');
}
function dealErrorBackCode(responseText){
	$("#errorcontent").text("服务器返回的数据无法识别，请将下面这段代码提交给网站开发者。谢谢");
	$("#errorcontent").append(responseText);
	$("#errormessage").modal('show');
}
function activeSubmit(){
    $.ajax({
   		type: "POST",
    	dataType: "json",
    	url:"home.php?mod=home&node=home&op=post&ajax=true",
    	data:$('#stuactivesubmit').serialize(),
    	complete:function (e) {
    		$('#stuactivesubmit')[0].reset();
    		try{ 
    			var json = eval(e.responseJSON);
	    		if(json["state"]==0){
	    			errorShow("操作失败，服务器返回："+json["message"]);
		    		return;
		  	 	}else{
		  	 		resultShow(json["message"]);
		  	 		requestActive(1);
    		  	 	return;
        		}
    		}catch(err){
    			dealErrorBackCode(e.responseText);
    			return;
		    }
    	}
    });
	
}
</script>

<style>
.ui.main.container {
	padding-top: 2cm;
}

.stuactive.form {
	padding-top: 0.5cm;
}
</style>

<div class="ui main container"
	id="<?php global $isOwner;echo $isOwner?"owner":"visitor"?>"
	uid="<?php global $uid;echo $uid;?>">
	<h1 class="ui header">家园</h1>
	<div class="ui attached stackable menu">
		<div class="ui container">
			<a class="item hm_item_home" id="hm_item_home"> <i class="home icon"></i>
				<?php echo $isOwner?"我的家园":"TA的家园"?>
			</a> <a class="item hm_item_message" id="hm_item_message"> <i
				class="mail icon"></i>
				<?php echo $isOwner?"留言板":"我给TA的留言"?>
			</a>
			 <?php if($isOwner){?> 
			 <a class="item hm_item_edit" id="hm_item_edit"> <i
				class="grid layout icon"></i> 个人信息编辑
			</a>
			<?php }?>
		</div>
	</div>
	<div class="ui internally celled grid" style="padding-top: 0.3cm">
		<div class="row">
			<div class="three wide column computer only tablet only">
				<div class="ui card">
					<img class="ui small image" src="../image/testhead.png">
					<div class="content">
						<a class="header"><?php global $name;echo $name;?></a>
						<div class="descriFption"><?php global $introduction;echo $introduction;?></div>
					</div>
				</div>
			</div>
			<div class="thirteen wide column maincl">
			<?php if($isOwner){?>
				<form class="ui form" id="stuactivesubmit">
					<input type="hidden" name="actiontype" value="active">
					<div class="field">

						<label>发表一个动态</label>
						<textarea rows="4" name="text"></textarea>
					</div>
					<div class="ui fluid large submit button"
						onClick="javascript:activeSubmit();">发表</div>
				</form>
				<?php } else {?>
				<form class="ui form" id="stuactivesubmit">
					<input type="hidden" name="actiontype" value="leavemessage"> <input
						type="hidden" name="target" value="<?php echo $uid;?>">
					<div class="field">
						<label>给TA留言</label>
						<textarea rows="4" name="text"></textarea>
					</div>
					<div class="ui fluid large submit button"
						onClick="javascript:activeSubmit();">留言</div>
				</form>
				<?php }?>
			</div>
		</div>
		<div class="row">
			<div class="three wide column computer only tablet only">
				<table class="ui selectable celled table">
					<thead>
						<tr>
							<th><?php echo $isOwner?"我的信息":"TA的信息"?></th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><?php global $name;echo $name; ?></td>
						</tr>
						<tr>
							<td><?php global $gender;echo ($gender==1?"男":"女"); ?></td>
						</tr>
						<tr>
							<td><?php global $grade;global $class; echo $grade."年级".$class."班"?></td>
						</tr>
						<tr>
							<td><?php echo $uid;?></td>
						</tr>
						<tr>
							<td><?php global $mail;echo $mail;?></td>
						</tr>

					</tbody>
				</table>
			</div>
			<div class="thirteen wide column maincl" id="stuhomehs"></div>
			<div class="ui dimmer">
				<div class="ui loader"></div>
			</div>
		</div>
	</div>
</div>


<div class="comment stucomment" id="commenttemple"
	style="display: none;">
	<a class="avatar"> <img class="stucomment header"
		src="../image/testhead.png">
	</a>
	<div class="content">
		<a class="author"> <!-- author id -->
		</a>
		<div class="metadata">
			<span class="date"> <!-- time -->
			</span>
		</div>
		<div class="text">
			<!-- content -->
		</div>
		<div class="actions">
			<a class="reply rep"> <!-- reply -->
			</a> <a class="reply ">删除</a>
		</div>
		<div class="stucomment ex"></div>
	</div>
</div>


<div class="ui modal" id="errormessage">
	<div class="header">我们似乎遇到了一些问题</div>
	<div class="content" id="errorcontent">
		<p></p>
	</div>
	<div class="actions">
		<div class="ui approve button">知道了</div>
	</div>
</div>

<div class="ui mini modal" id="resultmessage">
	<div class="header">操作结果</div>
	<div class="content" id="resultcontent">
		<p></p>
	</div>
	<div class="actions">
		<div class="ui approve button">知道了</div>
	</div>
</div>